﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Specialized;

public partial class khtjresult : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }
        
        CreateView();

    }

    protected void CreateView()
    {
          NameValueCollection m_args = Request.QueryString;

          string strttxt = "";

          if (m_args != null)
          {
              string strks = m_args["ks"].ToString();
              string strjs = m_args["js"].ToString();
              
              string strdatasmap = string.Format("{0}到{1}",strks,strjs);

              string strSql = string.Format("select count([id]) as cnt from [fangwen] where [dt]>='{0}' and [dt]<='{1}'",strks,strjs);
              ManageData md = new ManageData(util.DATACONNECTION);
              if (md != null)
              {
                  DataSet ds = md.ExecDS(strSql);
                  if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 )
                  {
                      DataRow dr = ds.Tables[0].Rows[0];

                      strttxt += string.Format("<tr><td>所有的客户</td><td align=\"center\">{0}</td><td align=\"center\">{1}</td></tr>", strdatasmap,dr["cnt"]);                      
                  }

                  strSql = string.Format("select count([id]) as cnt from [fangwen] where [dt]>='{0}' and [dt]<='{1}' and [type] = '0'", strks, strjs);

                  DataSet ds1 = md.ExecDS(strSql);
                  if (ds1 != null && ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
                  {
                      DataRow dr = ds1.Tables[0].Rows[0];
                      strttxt += string.Format("<tr><td>来电客户</td><td align=\"center\">{0}</td><td align=\"center\">{1}</td></tr>", strdatasmap, dr["cnt"]);
                  }

                  strSql = string.Format("select count([id]) as cnt from [fangwen] where [dt]>='{0}' and [dt]<='{1}' and [type] = '1'", strks, strjs);

                  DataSet ds2 = md.ExecDS(strSql);
                  if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                  {
                      DataRow dr = ds2.Tables[0].Rows[0];
                      strttxt += string.Format("<tr><td>来访客户</td><td align=\"center\">{0}</td><td align=\"center\">{1}</td></tr>", strdatasmap, dr["cnt"]);
                  }
              }


          }
          this.Literal1.Text = strttxt;

    }
}
